# main.py
from publisher.server import run
from controllers.metadatacontroller import MetaDataAPI

class MetaProxy(MetaDataAPI):
    def validate_album_access(self, user, albumid):
        return True
    def validate_photo_access(self, user, photoid):
        return True
    def path_for_photo(self, photoid):
        return self.get_photo(photoid).path
    def thumbnail_for_photo(self, photoid):
        return None
    def photo_data(self, photoid):
        '''name, path'''
        return self.get_photo(photoid).todict()
    def album_data(self, albumid):
        """pass control to self.album_data_callback"""
        return self.get_album(albumid).todict()
    def discover(self, user):
        """pass control to self.discover_callback"""
        return dict((x.id, (x.todict(), [y.todict() for y in x.images])) for x in self.get_albums())

def main():
    from IoC import ServiceLocator
    sl = ServiceLocator()

    sl.provide("metaregistry", MetaProxy)
    run()

if __name__ == "__main__":
    main()